﻿using FluentNHibernate.Mapping;

namespace ControleRepresentante.Logic.Models.Maps
{
    public class FabricaMap : SubclassMap<Fabrica>
    {
        public FabricaMap()
        {
            Map(x => x.Nome)
                .Not.Nullable();
            Map(x => x.CNPJ);
            Map(x => x.InscricaoEstadual);
            HasMany(x => x.Pedidos)
                .Access.PascalCaseField(Prefix.mUnderscore)
                .Cascade.Delete()
                .Inverse();
            HasOne(x => x.FabricaJolitex)
                .Cascade.All();
            HasOne(x => x.FabricaTrivium)
                .Cascade.All();
        }
    }

    public class FabricaJolitexMap : MapBase<FabricaJolitex>
    {
        public FabricaJolitexMap()
        {
            Map(x => x.IsJolitex)
                .Not.Nullable();
            HasOne(x => x.Fabrica);
        }
    }

    public class FabricaTriviumMap : MapBase<FabricaTrivium>
    {
        public FabricaTriviumMap()
        {
            Map(x => x.IsTrivium)
                .Not.Nullable();
            HasOne(x => x.Fabrica);
        }
    }
}
